﻿/*************************************************************************************
 * 工    具：  HK_ShortCutsExtension
 * 
 * 描    述：  设置Unity中常用命令的快捷键
 * 
 * 版    本：  V1.0
 * 作    者：  京产肠饭
 * 
 * 创    建：  2022/03/27  V1.0
 * 
 * 链    接：  https://gitee.com/JingChanChangFan/hk_-unity-tools
*************************************************************************************/

using UnityEditor;
using UnityEngine;

namespace HKTools
{
    public class HK_ShortCutsExtension
    {
        [MenuItem("HKTools/Find References In Scene %&z", priority = HK_MenuPriority.HK_FindReferences)]
        static void FindReferencesInScene()
        {
            EditorApplication.ExecuteMenuItem("Assets/Find References In Scene");
        }

        [MenuItem("Assets/Copy Absolute Path %&x", priority = HK_MenuPriority.HK_CopyAbsolutePath)]
        static void CopyAbsolutePath()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (!string.IsNullOrEmpty(path))
            {
                string fullPath = Application.dataPath.Replace("Assets", "") + path;
                EditorGUIUtility.systemCopyBuffer = fullPath;
                Debug.Log("复制的绝对路径如下: " + fullPath);
            }
            else
            {
                Debug.LogWarning("No asset selected");
            }
        }

        [MenuItem("Assets/Copy Absolute Path %&x", true, priority = HK_MenuPriority.HK_CopyAbsolutePath)]
        static bool CopyAbsolutePathValidation()
        {
            return Selection.activeObject != null;
        }
    }
}